<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>删除库存车辆 | 电动车销售系统</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/warehouse/deleteStock.css">
</head>
<body>
<header class="dashboard-header">
  <div class="container">
    <div class="d-flex justify-content-between align-items-center">
      <div>
        <h1 class="h3 mb-0"><i class="bi bi-bicycle"></i> 电动车销售管理系统</h1>
        <p class="mb-0 opacity-75">仓库管理 - 删除库存车辆</p>
      </div>
      <div class="d-flex align-items-center">
        <div class="me-3">
          <span class="d-none d-md-inline">仓库管理员</span>
          <div class="badge bg-light text-dark">
            <i class="bi bi-person-circle me-1"></i> 仓库管理员
          </div>
        </div>
        <div class="dropdown">
          <button class="btn btn-light rounded-circle p-1" type="button" data-bs-toggle="dropdown">
            <i class="bi bi-gear fs-5"></i>
          </button>
          <ul class="dropdown-menu dropdown-menu-end">
            <li><a class="dropdown-item" href="${pageContext.request.contextPath}/change_password.jsp"><i class="bi bi-lock me-2"></i> 修改密码</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item text-danger" href="${pageContext.request.contextPath}/LogoutServlet"><i class="bi bi-box-arrow-right me-2"></i> 退出登录</a></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</header>

<div class="container py-4">
  <div class="form-container">
    <div class="form-header">
      <h2><i class="bi bi-trash3 me-2"></i>删除库存车辆</h2>
      <p>从系统中移除不再售卖的电动车库存</p>
    </div>

    <!-- 警告图标 -->
    <div class="warning-icon">
      <i class="bi bi-exclamation-triangle"></i>
    </div>

    <!-- 信息提示框 -->
    <div class="info-box">
      <p><i class="bi bi-info-circle"></i> 此操作将永久删除库存记录，无法恢复</p>
      <p><i class="bi bi-info-circle"></i> 请谨慎操作，确保输入正确的库存ID</p>
      <p><i class="bi bi-info-circle"></i> 删除前请确认该库存车辆已不再销售</p>
    </div>

    <!-- 删除库存车辆信息消息提示 -->
    <c:if test="${not empty successMsg}">
      <div class="alert-message success-message">
        <i class="bi bi-check-circle-fill"></i>
        <div>${successMsg}</div>
      </div>
    </c:if>
    <c:if test="${not empty errorMsg}">
      <div class="alert-message error-message">
        <i class="bi bi-exclamation-circle-fill"></i>
        <div>${errorMsg}</div>
      </div>
    </c:if>

    <a href="/web/warehouse/warehouse_admin.jsp" class="back-link">
      <i class="bi bi-arrow-left"></i> 返回仓库管理菜单
    </a>

    <form action="/web/DeleteStockServlet" method="post">
      <div class="form-group">
        <label for="id" class="form-label">请输入要删除的车辆库存ID：</label>
        <input type="number" id="id" name="id" class="form-control"
               placeholder="例如：1" min="1" required
               oninput="validity.valid||(value='');">
      </div>
      <button type="submit" class="btn-submit">
        <i class="bi bi-trash3"></i> 确认删除库存车辆
      </button>
    </form>

    <div class="action-links">
      <a href="/web/StockQueryServlet" class="back-link">
        <i class="bi bi-list-ul"></i> 返回库存列表
      </a>
      <a href="/web/InboundQueryServlet" class="back-link">
        <i class="bi bi-clipboard-data"></i> 查看入库单记录
      </a>
    </div>
  </div>
</div>

<footer>
  <div class="footer-content">
    <p>&copy; 2025 电动车销售管理系统 - 仓库管理模块</p>
    <p>安全操作，谨慎管理库存</p>
  </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
  // 自动关闭消息提示
  setTimeout(() => {
    document.querySelectorAll('.alert-message').forEach(alert => {
      alert.style.opacity = '0';
      setTimeout(() => {
        alert.style.display = 'none';
      }, 500);
    });
  }, 5000);

  // 表单提交确认
  document.querySelector('form').addEventListener('submit', function(e) {
    const idInput = document.getElementById('id');
    if (!idInput.value) {
      e.preventDefault();
      alert('请输入要删除的库存ID');
      return;
    }

    if (!confirm('确定要删除ID为 ' + idInput.value + ' 的库存记录吗？此操作不可撤销！')) {
      e.preventDefault();
    }
  });
</script>
</body>
</html>